package com.starling.core
{
	import flash.display.BlendMode;
	import flash.display.DisplayObject;
	import flash.filters.BlurFilter;
	import flash.filters.ColorMatrixFilter;
	import flash.filters.DropShadowFilter;
	import flash.filters.GlowFilter;
	import flash.geom.ColorTransform;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.utils.getQualifiedClassName;

	public class InfoDisplay
	{
		/**
		 * 基础信息 
		 * @param display
		 * @param scale
		 * @return 
		 * 
		 */		
		public static function getInfo(display:DisplayObject ,scale:Number):Object
		{
			var rect:Rectangle = display.getBounds(display.parent);
			
			return {
				name:display.name,
				x:BNumber.formatNumber(display.x * scale ,2),
				y:BNumber.formatNumber(display.y * scale ,2),
				width:BNumber.formatNumber(rect.width ,2),
				height:BNumber.formatNumber(rect.height ,2),
				scaleX:BNumber.formatNumber(display.scaleX ,2),
				scaleY:BNumber.formatNumber(display.scaleY ,2),
				skewX:MatrixTransformer.getSkewX(display.transform.matrix),
				skewY:MatrixTransformer.getSkewY(display.transform.matrix),
				alpha:display.alpha,
				blend:getBlend(display),
				filters:getFilters(display),
				colorTransform:getColorTransform(display)
			};
		}
		
		
		
		/**
		 * 滤镜 
		 * @param display
		 * @return 
		 * 
		 */		
		private static function getFilters(display:DisplayObject):Array
		{
			if(display.filters.length<1)return null;
			
			var filters:Array = new Array();
			for (var i:int=0;i<display.filters.length;i++)
				filters.push({type:getQualifiedClassName(display.filters[i]) ,value:display.filters[i]});
			return filters;
		}
		
		
		
		
		/**
		 * 混合模式 
		 * @param display
		 * @return 
		 * 
		 */		
		private static function getBlend(display:DisplayObject):String
		{
			if(display.blendMode==BlendMode.NORMAL)return null;
			return display.blendMode;
		}
		
		
		
		
		/**
		 * 颜色效果 
		 * @param display
		 * @return 
		 * 
		 */		
		private static function getColorTransform(display:DisplayObject):Object
		{
			var ctf:ColorTransform = display.transform.colorTransform;
			if(
				ctf.redMultiplier!=1 ||
				ctf.redOffset!=0 ||
				ctf.greenMultiplier!=1 ||
				ctf.greenOffset!=0 ||
				ctf.blueMultiplier!=1 ||
				ctf.blueOffset!=0 ||
				ctf.alphaMultiplier!=1 ||
				ctf.alphaOffset!=0
			){
				return ctf;
			}
			
			return null;
		}
	}
}